#ifndef __TASKQUEUE_H__
#define __TASKQUEUE_H__
#include <condition_variable>
#include <iostream>
#include <queue>
#include <mutex>
#include <type_traits>
#include <thread>
#include <functional>
using std::queue;
using std::mutex;
using std::condition_variable;

class task;
class TaskQueue{
    using ElemType = std::function<void()>;
public:
    TaskQueue(size_t capa);
    ~TaskQueue();
    void push(ElemType &&ele);
    ElemType pop();
    bool empty();
    bool full();
    void wakeup();
private:
    size_t _capacity;
    queue<ElemType> _que;
    mutex _mutex;
    condition_variable _notEmpty;
    condition_variable _notFull;
    bool _flag;
};

#endif

